// functionPage/pages/secretary/noticeInfo/noticeInfo.js
const app = getApp();
import Http from '../../../../utils/http.js';
const http = new Http();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        review: '', //审核字段
        city: '',
        country: '',
        lat: '',
        lng: '',
        createuid: '',
        realnapicurl: '',
        realname: '',
        createtime: '',
        sceneImageArr: [],
        address: '',
        content: '',
        title: '',
        id: '',
        // 当前创建人id
        activeCreateUid: '',
    },
    // 查看他人主页
    jumpOthersPage(e) {
        wx.navigateTo({
            url: `/functionPage/pages/othersHomePage/othersHomePage?uid=${e.currentTarget.dataset.uid}`,
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        if (options.id) {
            this.setData({
                review: options.review || '',
                id: options.id,
            });
            this.getNoticeDetail(options.id);
        }
    },

    // 查询车食住行详情
    getNoticeDetail(id) {
        http.getRequest(
            `cjMap/getCityNoticeDetail?authId=${app.globalData.authId}&id=${id}`
        ).then((res) => {
            console.log(res);
            wx.setNavigationBarTitle({
                title: '城市公告·' + res.experience.city,
            });
            this.setData({
                city: res.experience.city,
                country: res.experience.country,
                lat: res.experience.lat,
                lng: res.experience.lng,
                activeCreateUid: res.experience.createuid,
                createuid: res.experience.createuid,
                realnapicurl: res.experience.realnapicurl,
                realname: res.experience.realname,
                createtime: res.experience.createtime,
                address: res.experience.address,
                content: res.experience.content,
                title: res.experience.title,
                sceneImageArr: res.experience.picurl
                    ? JSON.parse(res.experience.picurl)
                    : [],
            });
        });
    },

    // 导航
    navigate() {
        let _that = this;
        wx.openLocation({
            latitude: _that.data.lat,
            longitude: _that.data.lng,
            name: '详细地址',
            address: _that.data.address,
        });
    },

    // 预览图片
    previewImage(e) {
        let index = e.currentTarget.dataset.index;
        wx.previewImage({
            current: this.data.sceneImageArr[index],
            urls: this.data.sceneImageArr,
        });
    },
});
